<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;

$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['diy']=$this->plugin_setting('diy');
$basic=$this->plugin_setting('basic');
$return['basic']=$basic;
$return['setting']=$basic;
$keywords=$this->plugin_setting('search');
if($_RQ['op']=='main'){
	$return['params']=array();
	$return['list']=array();
	set_html('title','全部优惠接力活动');
	$return['sharedata']=array(
		'title'=>$basic['share_title'],
		'desc'=>$basic['share_desc'],
		'link'=>custom_url('jy_yousetli/index/'),
		'imgUrl'=>ATTACHMENT_URL.$basic['share_image'],
	);
	exi($return);
}
// js 获取数据
if($_RQ['op']=='getlist'){
	$params=array(
		'uniacid'=>$_SESSION['uniacid'],
		'status'=>1,
	);
	if(trim($_RQ['keywords'])){
		$params['title like']='%'.trim($_RQ['keywords']).'%';
	}

	//进一步整理筛选条件，商品属性字段是否需 要调整，商品分类如何筛选，orderby如何整理
	$pindex = max(1, intval($_RQ['page']));
	$psize = 20;
	if($_RQ['num']){
		$psize=$_RQ['num'];
	}
	$total='';
	$fields=array('id','uniacid','couponids','title','image','only_member','createtime','endtime','starttime','status');
	$orderby='id desc ';
	$act=pdo_getslice('jy_yousetli_act',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	$list=array();
	if($act){
		foreach($act as &$item){
			$item['starttime']=strtotime($item['starttime']);
			$item['endtime']=strtotime($item['endtime']);
			//if(time()>=$item['starttime']&&time()<=$item['endtime']){
				array_push($list,$item);
		//	}
			
		}
	}
	//获取商品活动信息
	if($list){
		foreach($list as &$item){
	
		}
	}
	$return['list']=$list;
	//print_r($list);exit;
	exi($return);
}